package 每日一题;

import javax.crypto.spec.PSource;

public class CM72另类加法 {
    public static int addAB(int A, int B) {
        // write code here
        //位运算
        if (A==0) {
            return B;
        }

        int sum=0;
        int carry=0;
        while (B!=0) {
            sum = (A^B);
            carry = (A&B) << 1;
            A=sum;
            B=carry;
        }
        return A;
    }

    public static void main(String[] args) {
        System.out.println(addAB(3, 5));
    }
}
